<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_patrimonio.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="EDITAR NOTA FISCAL"/>
				</h2>
				<hr />

				<p:messages id="msg" />
				
				<div align="center">
				<p:fieldset legend="Pesquisar">
				
				<h:outputLink value="javascript:void(0)" onclick="dlgNotaFiscal.show();">
					<h:outputLabel value="Pesquisar" rendered="#{empty notaFiscalBean.nota.id}"/>
					<h:outputLabel value="Nota Fiscal: " rendered="#{not empty notaFiscalBean.nota.id}"/>
				</h:outputLink>
				
				<h:outputLink value="javascript:void(0)" onclick="dlgNotaFiscal.show();">
				<h:graphicImage value="resources/img/lupa3.png" style="width: 40px;" onclick="dlgNotaFiscal.show();" rendered="#{empty notaFiscalBean.nota.id}" />
					<h:outputText id="nf" value="#{notaFiscalBean.nota.numero}" onclick="dlgNotaFiscal.show();" style="text-align: center; float: center; font-weight:bold;" rendered="#{not empty notaFiscalBean.nota.id}" />
				</h:outputLink>
				
				</p:fieldset>
				</div>
				
				<p:fieldset>
				
				<h:outputLabel value="Nota Fisal: " for="nota" style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<h:outputText id="nota" value="#{notaFiscalBean.nota.numero}" /><br /><br />
				
				<h:outputLabel value="Empenho: " for="empenho" style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<h:outputText id="empenho" value="#{notaFiscalBean.nota.empenho.numero}" /><br /><br />
				
				<h:outputLabel value="Fornecedor: " for="fornecedor" style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<h:outputText id="fornecedor" value="#{notaFiscalBean.nota.fornecedor.nome}"/><br /><br />
				
				<h:outputLabel value="Número: " for="numero" style="color: #87CEFA; font-weight:bold;" />
				<h:outputText id="numero" value="#{notaFiscalBean.nota.numero}" /><br /><br />
				
				
				<h:outputLabel value="Data de Emissão: " style="color: #87CEFA; font-weight:bold;" />&nbsp;&nbsp;
				<p:calendar value="#{notaFiscalBean.nota.data.time}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</p:calendar>&nbsp;&nbsp;&nbsp;
				
				<h:outputLabel value="Recebido: " style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<h:outputText value="#{notaFiscalBean.nota.recebido.time}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</h:outputText><br /><br />
				
				<h:outputLabel value="Enviada Para Pagamento: " style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<p:inputMask value="#{notaFiscalBean.nota.paga}" mask="99/99/9999">
					<f:ajax event="change" />
				</p:inputMask><br /><br />
				
				<h:outputLabel value="Valor Total: " for="valor" style="color: #87CEFA; font-weight:bold;" />
				<h:outputText id="valor" value="#{notaFiscalBean.nota.valor_total}">
					<f:convertNumber pattern="#00.00" />
				</h:outputText><br /><br /><br />

				<h:outputLabel value="Status: " for="status" style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<h:selectOneMenu id="status" value="#{notaFiscalBean.nota.status}">
					<f:selectItem itemLabel="" noSelectionOption="true" ></f:selectItem>
					<f:selectItem itemLabel="Recebido" itemValue="Recebido" />
					<f:selectItem itemLabel="Enviada Para Pagamento" itemValue="Enviada Para Pagamento" />
					<f:selectItem itemLabel="Pendente" itemValue="Pendente" />
					<f:selectItem itemLabel="Aguardando Material" itemValue="Aguardando Material" />
				</h:selectOneMenu><br /><br />
				
				<h:outputLabel value="Observação: " for="obs" style="color: #87CEFA; font-weight:bold;" />&nbsp;
				<h:outputText id="obs" value="#{notaFiscalBean.nota.obs}" />
				<br /><br />

				<p:commandButton id="grava" value="GRAVAR" action="#{notaFiscalBean.grava}" ajax="false" image="ui-icon-disk" rendered="#{not empty notaFiscalBean.nota.id}">
					<f:ajax render="@all" />
				</p:commandButton>	
				&nbsp;
				
				<p:commandButton id="cancel" value="CANCELAR EDIÇÃO" action="formAlterNotaFiscal.xhtml"
						rendered="#{not empty notaFiscalBean.nota.id}" ajax="false" icon="ui-icon-arrowreturnthick-1-w">
						<f:ajax render="@all" />
					</p:commandButton>
				<p />
				
				</p:fieldset>
				
<!-- 				<p:dataTable id="listNota" value="#{notaFiscalBean.notas}" -->
<!-- 					var="nota" paginator="true" selectionMode="single" rows="5" style="font-size: 11px"> -->
					
<!-- 					<p:ajax event="rowSelect" update="form" oncomplete="empeDialog.show()" />  -->

<!-- 					<f:facet name="header"> -->
<!-- 						<h:outputText value="NOTAS FISCIAS CADASTRADAS" /> -->
<!-- 					</f:facet> -->

<!-- 					<p:column sortBy="#{nota.numero}" filterBy="#{nota.numero}" filterMatchMode="contains" -->
<!-- 						headerText="Número" style="width: 100px;"> -->
<!-- 						<h:outputText value="#{nota.numero}" /> -->
<!-- 					</p:column> -->
					
<!-- 					<p:column sortBy="#{nota.empenho.numero}" filterBy="#{nota.empenho.numero}" filterMatchMode="contains" -->
<!-- 						headerText="Empenho" style="width: 150px;"> -->
<!-- 						<h:outputText value="#{nota.empenho.numero}" /> -->
<!-- 					</p:column> -->

<!-- 					<p:column sortBy="#{nota.fornecedor.nome}" filterBy="#{nota.fornecedor.nome}" filterMatchMode="contains" -->
<!-- 						headerText="Fornecedor"> -->
<!-- 						<h:outputText value="#{nota.fornecedor.nome}" />	 -->
<!-- 					</p:column> -->
					
<!-- 					<p:column sortBy="#{nota.data}" headerText="Data de Emissão"> -->
<!-- 						<h:outputText value="#{nota.data.time}"> -->
<!-- 							<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" locale="pt_BR" /> -->
<!-- 						</h:outputText>	 -->
<!-- 					</p:column> -->
					
<!-- 					<p:column sortBy="#{nota.status}" headerText="Status" style="width: 200px;"> -->
<!-- 						<h:outputText value="#{nota.status}" />			 -->
<!-- 					</p:column> -->

<!-- 					<p:column headerText="Ações" style="width: 30px;"> -->

<!-- 						<p:commandButton id="button" value="Editar" update="form" image="ui-icon-pencil"> -->
<!-- 							<f:setPropertyActionListener target="#{notaFiscalBean.nota}" value="#{nota}" /> -->
<!-- 						</p:commandButton> -->
						
<!-- 					</p:column> -->
											
<!-- 				</p:dataTable> -->
				

			</h:form>
			
			<p:dialog header="Notas Cadastradas" widgetVar="dlgNotaFiscal" model="true" width="800" showEffect="hide">
					<h:form id="form1">

						<p:outputPanel id="nfs">
							<p:dataTable value="#{notaFiscalBean.notas}" var="nota" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{nota.numero}" filterMatchMode="contains"
									headerText="Numero">
									<h:commandLink value="#{nota.numero}" onclick="dlgNotaFiscal.hide()"
										id="nota">
										<f:setPropertyActionListener
											target="#{notaFiscalBean.nota}" value="#{nota}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Fornecedor">
									<h:outputText value="#{nota.fornecedor.nome}" />
								</p:column>
								
								<p:column headerText="Empenho">
									<h:outputText value="#{nota.empenho.numero}" />
								</p:column>		
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
				
		</div>


	</ui:define>
</ui:composition>
</html>